# These tutorials are from youtube channel-theReimber
# Making the GUI - Tutorial 1
import sys
from tkinter import *
# from tkinter.ttk import *
  
mainWindow = Tk()

mainWindow.geometry("300x100+400+150")              # Create a new window
mainWindow.title("Grid Layout Manager")       
# Either code 1 will run or code 2. Both will not work together because two different layouts can't work at the same time
'''
# Code 1
# Labels - Tutorial 2
label1 = Label(text="This is label 1")
label1.pack()
label2 = Label(text="This is label 2").pack()
label3 = Label(text="This is Label 3", fg='red', bg='blue').pack()
    
# Grid() and Place() functions - Tutorial 3
# The pack command puts a widget in the centre of the window row.
# To put a widget elsewhere, we use the grid() and place() functions
    
# Place() is used for absolute placement at certain pixel values
label4 = Label(text="This is label 4").place(x=50, y=60)
'''

# Code 2
# Grid() works with rows and columns. It is considered more flexible as compared to place().
# Size of the grid expands or retracts based on the size of the widget.
# sticky keyword takes care of alignment.
# Width of the column is determined by the width of the longest widget
# If we remove the .geometry() function in the start, our window size will be the size of the grid
label5 = Label(text="Label 5", bg="red").grid(row=0, column=0, sticky=W)
label6 = Label(text="Label 6 is a longer label", bg="magenta").grid(row=1, column=0)
label7 = Label(text="This is Label 7",bg="blue").grid(row=1, column=1)
label8 = Label(text="Label 8",bg="green").grid(row=2, column=0, sticky=E)

mainWindow.mainloop()

